package com.k.kpp.dao;

import com.k.kpp.model.UserReq;
import com.k.kpp.model.entity.User;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author k
 */
@Repository
public interface UserMapper {
    /**
     * 查询用户
     * @return list
     */
    List selectAll();

    /**
     * count
     * @param req req
     * @return list
     */
    Long selectCount(UserReq req);

    /**
     * list by page
     * @param req req
     * @return list
     */
    List selectListByPage(UserReq req);

    /**
     * insert user
     * @param user u
     * @return records
     */
    int insertUser(User user);

    int deleteArr(Integer[] idArr);
    int deleteList(List<Integer> idList);

    /**
     * 查询
     * @param ids ids
     * @return List
     */
    @Select("<script>"  +
            "select " +
            " district_code " +
            "from smp_t_district_info where 1=1 and guid  in" +
            "<foreach item='item' index='index' collection='list' open='(' close=')' separator=','>" +
            "#{item}" +
            "</foreach> " +
            "order by" +
            " sort "+
            "</script>")
    @Results({
            @Result( column = "guid",property = "guid"),
            @Result( column = "district_code",property = "districtCode"),
            @Result(column = "district_type",property = "districtType"),
            @Result(column = "district_name",property = "districtName"),
            @Result(column = "sort",property = "sort"),
            @Result(column = "version",property = "version"),
            @Result(column = "create_user",property = "createUser"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_user",property = "updateUser"),
            @Result(column = "update_time",property = "updateTime"),
            @Result(column = "enable_flag",property = "enableFlag"),
    })
    List<User> customQueryByIds(List<String> ids);
}
